import React from "react";
import { LocalUtil } from "../utils/caches"

// 初始状态
export const initState = {
  userInfo: LocalUtil.get("userInfo") || {},  // 用户信息
};

// initReducer 用于修改状态
export const initReducer = (state, action) => {
  const { type, updata } = action;
  switch (type) {
    case "UpdataUserInfo":
      return {
        ...state,
        userInfo: updata,
      };
    default: {
      return state;
    }
  }
};

export const GlobalContext = React.createContext(null);


